package com.Xht.www.servlet;

//后端响应登录时黑户无法登录申请解封的请求

import com.Xht.www.dao.UserInfoDAO;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/user/submitUnblockRequest")
public class UserSubmitUnblockRequestServlet extends HttpServlet {
    private UserInfoDAO userInfoDAO = new UserInfoDAO();

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();

        String username = request.getParameter("username");
        if (userInfoDAO.updateUserStatusToUnblocking(username)) {
            out.write("{\"success\": true, \"message\": \"提交解封申请成功\"}");
        } else {
            out.write("{\"success\": false, \"message\": \"提交解封申请失败\"}");
        }
        out.close();
    }
}
